#include "virtualkeyboard.h"
#include "ui_virtualkeyboard.h"

VirtualKeyboard::VirtualKeyboard(QWidget *parent) :
    QWidget(parent, Qt::Tool),
    ui(new Ui::VirtualKeyboard)
{
    ui->setupUi(this);
    
    this->connect(ui->buttonGroup, SIGNAL(buttonPressed(QAbstractButton*)), this, SLOT(clicked(QAbstractButton*)));
}

VirtualKeyboard::~VirtualKeyboard()
{
    delete ui;
}

void VirtualKeyboard::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void VirtualKeyboard::clicked(QAbstractButton * button)
{

    if(button == ui->button_clear){
        emit clearSelected();
    }else if(button == ui->button_del){
        emit delSelected();
    }else if(button == ui->button_space){
        emit charSelected(QString(" "));
    }else{
        emit charSelected(button->text());
    }

}
